let index = 0

function P(val, time) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(val)
            index++
            if (index === 3) {
                console.log(val)
            }
        }, time);
    })
}

let p1 = P('hello', 10)
p1.then(val => {
    return P(val + ' lagou', 10)
}).then(val => {
    return P(val + ' I ❤️ U', 10)
})